//
//  MKUITableView.m
//  MKUI
//
//  Created by 苏尚进 on 2021/7/10.
//  Copyright © 2021 moon. All rights reserved.
//

#import "MKUITableView.h"
#import "UITableView+MKUI.h"

@implementation MKUITableView
- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style{
    if(self=[super initWithFrame:frame style:style]){
        self.model = [[MKUITableViewModel alloc] initWithTableView:self];
        if (@available(iOS 15.0, *)) {
            self.sectionHeaderTopPadding = 0;
        }
    }
    return self;
}
- (void)setModel:(MKUITableViewModel *)model{
    if(_model!=model){
        _model = model;
        [_model setTableViewDataSourceAndDelegate:self];
    }
}
- (CGSize)sizeThatFits:(CGSize)size{
    CGSize s = size;
    s.height = [self mk_heightThatFits:size.width];
    return s;
}
//#ifdef DEBUG
//- (void)setContentInset:(UIEdgeInsets)contentInset{
//    [super setContentInset:contentInset];
//}
//#endif
- (void)dealloc{
    //ios10时，会因为实现了scrollViewDidScroll：方法，导致闪退，需要手动清空delegate
    self.delegate = nil;
}
@end
